//
//  ShoppingCartPayView.m
//  WeiYiMei
//
//  Created by 李叶夫 on 2019/4/14.
//  Copyright © 2019年 liyefu. All rights reserved.
//

#import "ShoppingCartPayView.h"
#import "UIImage+Color.h"
#import "ANGradientButton.h"

@interface ShoppingCartPayView ()

@property (nonatomic, strong) UILabel *payTitleLab;
@property (nonatomic, strong) UILabel *payPriceLab;
@property (nonatomic, strong) ANGradientButton *payButton;

@end

@implementation ShoppingCartPayView

- (void)setupSubViews
{
    self.backgroundColor = kColorF2F2F2;
    self.payTitleLab = [[UILabel alloc] init];
    self.payTitleLab.textColor = kColor333333;
    self.payTitleLab.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.payTitleLab];
    
    self.payPriceLab = [[UILabel alloc] init];
    self.payPriceLab.textColor = kColorFF2C2C;
    self.payPriceLab.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.payPriceLab];
    
    self.payButton = [[ANGradientButton alloc] initWithFrame:CGRectMake(0, 0, kWidth(85), kWidth(32))];
    [self.payButton setTitle:@"去支付" forState:UIControlStateNormal];
    [self addSubview:self.payButton];
    self.payButton.titleLabel.font = [UIFont systemFontOfSize:14];
    self.payButton.layer.cornerRadius = kWidth(32)/2.0;
    self.payButton.layer.masksToBounds = YES;
    [self.payButton addTarget:self action:@selector(payAction) forControlEvents:UIControlEventTouchUpInside];
    
    self.payTitleLab.text = @"商品共0件，合计:";
    self.payPriceLab.text = @"￥0.00";
    
}

- (void)payAction
{
    if (self.payHandler) {
        self.payHandler();
    }
}

- (void)setTotalNum:(NSString *)totalNum
{
    self.payTitleLab.text = [NSString stringWithFormat:@"商品共%@件，合计:",totalNum];
}

- (void)setTotalPrice:(NSString *)totalPrice
{
    self.payPriceLab.text = [NSString stringWithFormat:@"￥%@",totalPrice];
}

- (void)clearData
{
    self.payTitleLab.text = @"商品共0件，合计:";
    self.payPriceLab.text = @"￥0.00";
}

- (void)setupConstraints
{
    [self.payButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self).offset(-kWidth(15));
        make.width.equalTo(@(kWidth(85)));
        make.height.equalTo(@(kWidth(32)));
    }];
    
    [self.payPriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self.payButton.mas_left).offset(-kWidth(24));
    }];
    
    [self.payTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self.payPriceLab.mas_left);
    }];
}

@end
